package com.favccxx.message.infrastructure.util.jackson;

import com.fasterxml.jackson.core.type.TypeReference;

import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;

public class CustomeTypeRef<T> extends TypeReference<T> {

    private Class<?> rawType, paramType;


    public CustomeTypeRef(Class<?> rawType, Class<?> paramType) {
        this.rawType = rawType;
        this.paramType = paramType;
    }

    @Override
    public Type getType() {
        return new ParameterizedType() {
            @Override
            public Type[] getActualTypeArguments() {
                return new Type[]{paramType};
            }

            @Override
            public Type getRawType() {
                return rawType;
            }

            @Override
            public Type getOwnerType() {
                return null;
            }
        };
    }
}

